<script setup>
import { inject } from "vue";

const username = inject('username')
const userInfo = inject('userInfo')
// 如果没有祖先组件提供 "message"
// `value` 会是 "这是默认值"
const value = inject('message', '这是默认值')
console.log(username, '==username');
console.log(userInfo, '==userInfo');
console.log(value, '==value');

const { location, updateLocation } = inject('location')
</script>
<template>
  <div>
    username: {{ username }}
    <button @click="updateLocation">{{ location }}</button>
  </div>
</template>

<style></style>
